package cn.wolfcode.luowowo.util;

import cn.wolfcode.luowowo.exception.LogicException;
import org.springframework.util.StringUtils;

public class AssertUtil {
    //判断字符串是否空
    public static void hasLength(String value, String msg) {
        /**
         * 判断字符串是否为空
         * 如果空就就抛异常
         *
         */
        if (!StringUtils.hasLength(value)) {
            throw new LogicException(msg);
        }
    }

    public static void isEquals(String password, String rpassword, String msg) {
        hasLength(password, "密码不能为空");
        hasLength(rpassword, "确认密码不能为空");
        if (!password.equals(rpassword)) {
            throw new LogicException(msg);
        }
    }
}
